package com.ujiuye.dao.impl;

import com.ujiuye.dao.StudentDao;
import com.ujiuye.entity.Student;
import com.ujiuye.util.DbutilsUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class StudentDaoimpl implements StudentDao {
    QueryRunner qr= DbutilsUtil.getQr();
    @Override
    public List<Student> getSearch(String content) {
      List<Student> list=null;
      String sql="select * from tb_student where sname like ? limit 5";
        try {
            list=qr.query(sql,new BeanListHandler<>(Student.class),"%"+content+"%");
            System.out.println(list);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }
}
